#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QSharedPointer>

#include <sio_client.h>
#include <string>
#include <map>

namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();


private:
    void onConnected(const std::string& nsp);
    void onClosed(const sio::client::close_reason& reason);
    void onFailed();
    void onMessage(const std::string& name,const sio::message::ptr& data,bool hasAck,sio::message::list &ack_resp);
    void onSendMessage();
    void onConnectServer();
    void onChannelChange(const QString& val);
private:
    typedef enum
    {
        CLOSED,
        OPENED,
        CONNECT_FAILD,
        RECONNECT
    } CONNECT_STATUS;
    Ui::Widget *ui;
    QSharedPointer<sio::client> m_io;
    int m_connectStatus;
    QString m_currentChannel;
    std::map<QString, sio::socket::ptr> m_channels;


};

#endif // WIDGET_H
